-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement toCsv #1
Conversation
@@ -0,0 +1,21 @@ | |||
import { toString } from "micro-dash"; | |||
|
|||
export function toCsv(data: any[][]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[green]
Maybe "content" instead of "data"?
const string = toString(value); | ||
|
||
if (/["|,|\n|\r]/.test(string)) { | ||
return wrapWithQuotes(string.replace(/"/g, `""`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[yellow]
Should these regular expressions be extracted into constants outside the function? Or doesn't that matter in javascript?
} | ||
|
||
function wrapWithQuotes(string: string) { | ||
return `"${string}"`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[green]
This implementation is shorter than the name of the function. Maybe inline it?
@@ -1,21 +1,20 @@ | |||
import { toString } from "micro-dash"; | |||
|
|||
export function toCsv(data: any[][]) { | |||
return data | |||
export function toCsv(content: any[][]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[red]
Documentation!
Implements
toCsv